<include file="Public:headern"/>
<link rel="stylesheet" href="__PUBLIC__/scripts/ui/redmond/jquery-ui-1.8.6.css">        
<script type="text/javascript" src="__PUBLIC__/scripts/ui/jquery-ui-1.8.6.min.js"></script>
<script src="__PUBLIC__/Static/Uploadify/jquery.uploadify-3.1.min.js"></script>
<link href="__PUBLIC__/Static/Uploadify/uploadify.css" rel="stylesheet">
<link rel="stylesheet" href="__PUBLIC__/js/treeview/jquery.treeview.css" />
<script src="__PUBLIC__/js/treeview/jquery.cookie.js"></script>
<script src="__PUBLIC__/js/treeview/jquery.treeview.js"></script>
<style>
.uploadify {
float:right;
margin-right:260px;
margin-top:4px;
}
.imagelist{}
.imagelist span{
    display: inline;
    float: left;
	margin-right:10px;
    width: 80px;
	height:60px;
	overflow:hidden;
	position: relative;
	
}
.imagelist span em{
    color: #999999;
    display: block;
    line-height: 18px;
    padding: 8px 0px;
}

.imagelist span span.txt {
	display:none;
    line-height:25px;
	height:25px;
    width: 80px;
	text-align:right;
	position:absolute;
	top:0px;
	right:0px;
}
.sp_p2 input {
    height: 40px;
    min-width: 180px;
    border: 1px solid #cecece;
    font-size: 15px;
}
</style>
<script>
$(function(){
	$("#browser").treeview({			
		  animated: "medium",
		});	

	$("#image_result").sortable();
	$('.imagelist span').live({
	   mouseenter:
	   function()
	   {
		  $(this).find('.txt').css('display','block');
	   },
	   mouseleave:
	   function()
	   {
		  $(this).find('.txt').css('display','none');
	   }
	});
	$("#upload").uploadify({
		height        : 30,
		swf           : '__PUBLIC__/Static/Uploadify/uploadify.swf',
		uploader      : '{:U("Uploadifym/upload")}',
		width         : 60,
		buttonText	  : '修改头像',
		auto		  : true,
		removeCompleted: false,
		onUploadSuccess: function(file, data, response) {
			//$('#progress').hide();
			var result = $.parseJSON(data);
			//错误处理。。。
			if(!data){alert(file.name+'上传失败'); return false;}
			if(result.status == 0){
				alert(file.name+result.message);
				return false;
			}
			//上传成功
			var id = Math.random().toString();
			id = id.replace('.','_'); //生成唯一标示
			var html = '<span class="imageitem" id="'+id+'">';
				html+= '<input type="hidden" name="headimg" value="'+result.file_name+'">'; //隐藏域，是为了把图片地址入库。。
				html+= '<input type="hidden" name="changeheadimg" value="1">'; //隐藏域，是为了把图片地址入库。。
				html+=  '<span class="txt">';
				html+=  '<a title="del" href=javascript:remove("'+result.file_name+'","'+id+'");><img src="__PUBLIC__/Static/Uploadify/remove.png" /></a>';
				html+=  '</span>';
				html+= '<img height="80" width="80" src="'+result.file+'" />';
				html+=  '</span>';
			$('#image_result').html(html);
		},
		/*  onUploadStart: function(){
			$('#progress').empty().append('<img src="__PUBLIC__/images/load.gif">');  //用户等待提示。
			$('#progress').show();
		},*/
		onInit: function (){  
			$("#upload-queue").hide(); //隐藏上传队列                
		}		 
	});
})
function remove(file,id){
	$.getJSON('{:U("Uploadifym/removeImg")}',{file:file},function(data){$('#'+id).remove()})
}
function removePic(uid){
	$.getJSON('{:U("removePic")}',{id:uid},function(data){$('#memberimg').remove()})
}
</script>
<div class="top"><a href="#"><img src="__PUBLIC__/Catalog/nimages/tb.png"/></a>
    <p>个人设置</p>
</div>

<div class="height25"></div> 
<form action="{:U('Membership/memberdetail')}" id="detail" method="post">
    <div class="S-form_box2">
      <p class="noneborder"><label>昵称：</label><input type="text"  id="name" name="name" value="{$membership.name}" placeholder="请输入" class="text" /></p>
      <p><label>会员号：</label>{$membership.member_id}</p>
      <p><label>头像：</label><span style="display:block;float:right;width:80px;"  class="ka1" id="upload"></span></p>
     
      	<p id="image_result" style="height:100px;">
   			<if condition="$membership['headimg'] neq '' || $membership['headimgurl'] neq ''">
   			<span id="memberimg">
	   			<input type="hidden" name="headimg" value="{$membership.headimg}">
	   			<span class="txt">
                    <a title="Delete" href='javascript:removePic({$membership.uid});'><img src="__PUBLIC__/Static/Uploadify/remove.png" /></a>
                 </span>
	   			<img src="<if condition="$membership['headimg'] neq ''">__PUBLIC__/images/memberhead/thumb/m_{$membership.headimg}<else/>{$membership.headimgurl}</if>" width="80" height="80" style="margin-top:10px;" />
	   		</span>
   			</if>
   	    </p>
     
      <p><label class="nobo">所在省份</label></p>
      <p class="spSelect">
      	{:W('Shengshi',array('now_city_id'=>$membership['citycode'],'now_prov_id'=>$membership['provcode'],'now_area_id'=>$membership['area_id']))}
      </p>
    </div>
    <div class="S-form_box"><input type="submit" id="tijiao" class="sub" value="确认修改" /></div>
</form>
<script>
$(function(){
    if('{$msg}'!='0'){
        alert('{$msg}');
    }
});

</script>
<include file="Public:footern" />
